const path = require('path');
const fs = require('fs');
const axios = require('axios');
const { Blob } = require('buffer');

// 需要上传的文件路径
const folderPath = `./build/js/index.js`;

// 上传文件
fs.readFile(folderPath, (err, data) => {
  if (err) {
    console.error('读取目录失败:', err);
    return;
  }
  if (data) {
    const blob = new Blob(data);
    console.log(blob, 'blob');
    axios
      .post(
        'http://123.57.78.161:8081/palm/ding/uploadCert.json',
        new URLSearchParams({ file: blob }),
      )
      .then((res) => {
        console.log(res.data, 'res----');
      });
  }
});
